import { MusicManager } from "../MusicManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Util {

    /**
     * 设置节点按下动画
     * @param node 
     * @returns 
     */
    public static clickDownTween(node?: cc.Node, callback?: () => void): void {
        if (!node) { return }

        // 播放按下音效
        MusicManager.getInstance().playClickEffect()

        cc.tween(node)
            .to(0.1, { scale: 0.8 })
            .call(() => {
                if (callback) { callback() }
            })
            .start()
    }

    public static clickUpTween(node?: cc.Node, callback?: () => void): void {
        if (!node) { return }

        cc.tween(node)
            .to(0.1, { scale: 1 })
            .call(() => {
                if (callback) { callback() }
            })
            .start()
    }
}
